//
//  LYTabbarController.h
//  LYTabbarDemo
//
//  Created by 刘宇 on 16/6/23.
//  Copyright © 2016年 liuyu. All rights reserved.
//

// :: Framework ::
#import <UIKit/UIKit.h>
// :: Other ::
#import "LYBar.h"
#import "LYNavigationController.h"
// RGB颜色
#define RGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

// 随机色
#define RandomColor RGBColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

@class LYTabbarController;

typedef NS_ENUM(NSInteger, LYError) {
    LYErrorNone,   //无错误
    LYErrorControllersNULL,  // controllers数组为空
    LYErrorImagesNULL,   //item 默认图片 的数组为空
    LYErrorSelectedImagesNULL, //item 选中时的图片 的数组为空
    LYErrorControllersAndImagesAndSelectedImagesCountDiff, //controllers,images,selectedImages数组个数不一致
};

@protocol LYTabbarControllerDelegate <UITabBarControllerDelegate>

@optional
/**
 *  已经点击tabbar上的中间按钮
 */
- (void)tabBarDidClickCenterButton;

- (void)tabBarController:(LYTabbarController    *)tabbarController error:(LYError)error;

@end




@interface LYTabbarController : UITabBarController


@property (nonatomic, strong) LYBar *customTabbar;

#pragma mark 数据源
/**
 *  childVCs tabbar上的controller数组
 */
@property (nonatomic, strong) NSArray<UIViewController  *> *childVCs;
/**
 *  images          tabbar item按钮的默认图片 数组
 *  selectedImages  tabbar item按钮的选中状态的图片 数组
 */
@property (nonatomic, strong) NSArray<NSString  *> *images;
@property (nonatomic, strong) NSArray<NSString  *> *selectedImages;


#pragma mark 中间按钮

/**
 *  中间按钮的样式
 *  LYCenterButtonStyleBulge 凸起
 *  LYCenterButtonStyleNOBulge 不凸起
 *  LYCenterButtonStyleDefault 默认 不凸起
 */
@property (nonatomic, assign) LYCenterButtonStyle   centerButtonStyle;
@property (nonatomic, strong) UIImage *centerImage; //中间按钮默认图片
@property (nonatomic, strong) UIImage *centerSelectedImage; //中间按钮点击后图片
@property (nonatomic, assign) CGRect centerBounds; //中间按钮尺寸
/**
 *  中间按钮位置偏移量 0~1，值越小垂直位置越靠上，值越大垂直位置越靠下
 */
@property (nonatomic, assign) CGFloat centerButtonOffset;
@property (nonatomic, assign) id<LYTabbarControllerDelegate> tabbarDelegate;
#pragma mark 初始化
- (instancetype)init;
#pragma mark 加载视图
/**
 *  添加视图、按钮图片、选中后的按钮图片
 *  此方法要在 该对象 加载在程序根视图前调用
 *
 *  @param items          视图数组
 *  @param images         tabbar item 默认图片数组
 *  @param selectedImages tabbar item 选中后的图片数组
 */
- (void)addChildViewControllers:(NSArray<UIViewController   *>*)childVCs images:(NSArray<NSString  *>*)images selectedImages:(NSArray<NSString  *>*)selectedImages;


@end
